#include "ScriptActionCreator.h"
#include "QTextBrowser"
#include "QAbstractListModel"

#include "LightPresetData.h"
#include "ActionTargetSelectorDialog.h"

/** html for light event */
#define  LIGHT_ACTION_HTML_HTML(name)  \
   QString("<p><a href=\"$$EVENT_LIGHT$$%1\"><span style=\" color: #11ddee; background: #ee4411; \">").arg(name) +\
           "<img src=\"file:light.png\"/></a>  <b>CHANGE LIGHT</b> ... </span></p>"

/** html for audio/video event */
#define  MEDIA_ACTION_HTML(path)  \
   QString("<p><a href=\"$$EVENT_MEDIA$$%1\"><span style=\" background: #1188ee; color: white\">").arg(path) +\
           "<img src=\"file:sound.png\"/></a>  <b>TRACK:</b> - ... </span></p>"

/** html for audio/video event */
#define  PICTURE_ACTION_HTML(path)  \
   QString("<p><a href=\"$$EVENT_PICTURE$$%1\"><span style=\" background: #1177ff; color: white\">").arg(path) +\
           "<img src=\"file:picture.png\"/></a>  <b>TRACK:</b> - ... </span></p>"

ScriptActionCreator::ScriptActionCreator(IF_ActionSelectorInterface &actionSelector) :
   m_actionSelector(actionSelector)
{
}

QString ScriptActionCreator::makeHtmlForLightAction()
{
   m_actionSelector.selectEvent( IF_ActionSelectorInterface::LightAction);
   return makeHtmlForAction();
}

QString ScriptActionCreator::makeHtmlForMediaAction()
{
   m_actionSelector.selectEvent( IF_ActionSelectorInterface::MediaAction);
   return makeHtmlForAction();
}

QString ScriptActionCreator::makeHtmlForAction()
{
   QString htmlForEvent;
   QString actionId = m_actionSelector.getActionId();

   if (m_actionSelector.getActionType() == IF_ActionSelectorInterface::LightAction)
   {
      htmlForEvent = LIGHT_ACTION_HTML_HTML(actionId);
   }
   else if (m_actionSelector.getActionType() == IF_ActionSelectorInterface::MediaAction)
   {
      htmlForEvent = MEDIA_ACTION_HTML(actionId);
   }
   else if (m_actionSelector.getActionType() == IF_ActionSelectorInterface::PictureAction)
   {
      htmlForEvent = PICTURE_ACTION_HTML(actionId);
   }

   return htmlForEvent;
}

